package dbcreation;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Test {


	public static void main( String args[] )
	  {
	    Connection c = null;
	    Statement stmt = null;
	    try {
	      Class.forName("org.sqlite.JDBC");
	      c = DriverManager.getConnection("jdbc:sqlite:becloud.db");
	      c.setAutoCommit(false);
	      System.out.println("Opened database successfully");

	      stmt = c.createStatement();
	      
	      //Il y a bien 3 tables
	  /*    ResultSet rs = stmt.executeQuery( "SELECT * FROM sqlite_master WHERE type='table' ORDER BY name;" );
	      while ( rs.next() ) {
	         String  name = rs.getString("tbl_name");
	         System.out.println( "NAME = " + name );
	         System.out.println();
	      }*/
	      
	      ResultSet rs = stmt.executeQuery( ".tables" );
	      while ( rs.next() ) {
	         String  name = rs.getString("SERVICES");
	         System.out.println( "NAME = " + name );
	         System.out.println();
	      }
	      
	      rs.close();
	      stmt.close();
	      c.close();
	    } catch ( Exception e ) {
	      System.err.println( e.getClass().getName() + ": " + e.getMessage() );
	      System.exit(0);
	    }
	    System.out.println("Operation done successfully");
	  }
	}